<template>
	<view class="cate">
		 <view class="cate-con">
			 <!-- 左边侧边栏 -->
			 <scroll-view scroll-y="true" class="left">
			 	<view class="name" :class="{active:currentIndex == index}" v-for="item,index in cateList" :key="index" @click="change(index)">
					{{item.categoryName}}
				</view>
			 </scroll-view>
			 <!-- 右边内容 -->
			 <scroll-view scroll-y="true" class="right">
			 	<view class="right-item" v-for="item,index in cateList[currentIndex].secondLevelCategoryVOS" :key="index">
					<view class="name">
						{{item.categoryName}}
					</view>
					<view class="third">
						<view class="third-item" v-for="ele,i in item.thirdLevelCategoryVOS" :key="i">
							<image src="../../static/logo.png" mode="" class="img"></image>
							<view class="title">
								{{ele.categoryName}}
							</view>
						</view>
					</view>
				</view>
			 </scroll-view>
		 	
		 </view>
	</view>
</template>

<script>
	import {getCateList} from '../../utils/api.js'
	export default {
		data() {
			return {
				cateList:[],
				currentIndex:0
			};
		},
		async onLoad() {
			// getCateList().then(res=>{
			// 	console.log(res);
			// })
			// await 可以直接拿到resolve的结果
			this.cateList = await getCateList()
			console.log(this.cateList);
			
		},
		methods:{
			change(i){
				this.currentIndex = i
			}
		}
	}
</script>
<style lang="scss">
.cate{
	height: 100vh;
	width: 100%;
	.cate-con{
		display: flex;
		height: 100%;
		width: 100%;
		.left{
			height: 100%;
			width: 220rpx;
			.name{
				height: 80rpx;
				line-height: 80rpx;
				
			}
			.active{
				color: aquamarine;
			}
		}
		.right{
			flex:1;
			.name{
				width: 100%;
				text-align: center;
			}
			.third{
				display: flex;
				align-items: center;
				flex-wrap: wrap;
				width: 100%;
				box-sizing: border-box;
				.third-item{
					font-size: 24rpx;
					text-align: center;
					// margin: 10px;
					width: 30%;
					box-sizing: border-box;
					
					.img{
						width: 80rpx;
						height: 80rpx;
					}
					
				}
			}
			
		}
		
	}
	
}
</style>
